package tech.aistar.corejava.day17.reflection.factory;

/**
 * Created by 豆梦寒 on 2019/8/6.
 */
public class BeanFactory {
    public static IPointDao getInstance(String key){
        IPointDao pointDao = null;

        //反射的方式来创建对象
        //获取class实例-获取类的全限定名
        String className = PropUtils.getValue(key);
        try {
            Class<?> c = Class.forName(className);
            pointDao = (IPointDao) c.newInstance();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
        return pointDao;
    }
}
